<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="shiyue" uri="http://www.shiyue.com" %>
<% 
 /**
  功能名称:公务员分组
  创建时间:2010-8-6
  创建人:
**/
%>
<%
String path = request.getContextPath();
%>
<html>
  <head>
    <title>公务员分组</title>
    <link href="<%=path %>/css/index_css.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="<%=path %>/css/paging.css">
    <script src="<%=path%>/js/resizeIframe.js" type="text/javascript"></script>
    <script src="<%=path%>/js/syAjax.js" type="text/javascript"></script>
    <script language="javascript" src="<%=path %>/js/paging.js"></script>
    <script src="<%=path%>/dwr/engine.js"></script>
	<script src="<%=path%>/dwr/util.js"></script>
	<script src="<%=path%>/dwr/interface/shiyueDwr.js"></script>
	<script type="text/javascript">	
      
      //点击保存或修改教师所在部门
      var tdId="";
      var isEditor=1;	//是否为编辑状态 0：可编辑 1：不可编辑
      function save(userId,orgId)
      {
        //判断是不是当前年度
        if(document.getElementById('year').value=='${applicationScope.currentYear}')
		{
      	//判断是否为可编辑状态
      	if(isEditor==0)
      	{
      	    tdId= arguments[2];
        	syAjax.request("post","<%=path%>/saveUserOrgRoleRelationroleAction.action","PORR.id.user.userId="+userId+"&PORR.id.role.roleId=member&currentPage=${currentPage}&PORR.id.organization.organizationId="+orgId,{success:initSaveResult,fail:onFail,type:'plain'});
      	}else{
      	  alert("请设为编辑状态!");
      	}
      	}
      	else
      	{
      		alert("不是当前年度，不能进行此操作！");
      	}
      }
      
      function initSaveResult(response){
 		if(response=="save")
 		{
 			document.getElementById(tdId).innerHTML="√";
 		}else if(response=="delete")
 		{
 			document.getElementById(tdId).innerHTML="";
        }else
        {
        	alert("您还未设置当前年度，不能进行分组");
        }
      }
      
      //改变编辑状态
   	  function changeEditor(a)
   	  {
   	    if(isEditor==0)
   	    {
   	    	a.innerHTML="<font color='#000000'>设为编辑状态</font>";
   	    	isEditor=1;
   	    }else{
   	    	a.innerHTML="<font color='red'>设为非编辑状态</font>";
   	    	isEditor=0;
   	    }
   	  }
   	  
   	  //年度的下拉列表框
   	  function getAllYearCallBack(yearMap) {
        DWRUtil.addOptions("year", yearMap);
        if('${year}'!="")
    	{
    	  document.getElementById('year').value="${year}";
    	}else if('${currentYear}'!="")
    	{
    	  document.getElementById('year').value="${currentYear}";
    	}
    	var objURL="";
		objURL= "<%=path%>/findOfficialToDepartmentorganizationAction.action?years="+document.getElementById('year').value+"&orgType=2&forwardPage=offToDepartment&currentPage=${currentPage}";		
		paging(objURL,pageInfo);
		resize();
    } 
    
  
    
  
    
    function tdClick(url)
    {
      window.location.href=url;
    }
    
    var pageInfo = ${shiyue:toJSONWithExclude(pageInfo, "class,pageData")};
	window.onload   =   function(){
		shiyueDwr.getAllYear(getAllYearCallBack);
		parent.location.hash="top";
		//分页
		var objURL= "<%=path%>/findOfficialToDepartmentorganizationAction.action?user.userType=${sessionScope.UserInfo.userType}&years=${applicationScope.currentYear}&orgType=2&forwardPage=offToDepartment";
		paging(objURL,pageInfo);
	};
	function resize(){
      	
      	resizeIframe();
        
          
        
      }
     //浮动表头 
      	function floatTr(obj)  {
		var ftr = document.getElementById('ftr');
		ftr.style.top= obj.scrollTop; 
	}
	

	</script>
  </head>
  
  <body>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>   
    <td colspan="2" align="left" class="f_5">部门成员管理</td>
  </tr>
  <tr>
    <td height="1" colspan="2" bgcolor="#9DD12E"></td>
  </tr>
  <tr>
    <td colspan="2" align="left" valign="top">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2" align="left">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td align="left" valign="bottom" background="<%=path%>/images/sywesp_24.gif">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="90" align="left">
            <table width="90" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="1" align="left" valign="bottom" bgcolor="#CBCBCB"></td>
                <td align="center" background="<%=path%>/images/sywesp_25.gif" class="f_9">部门分组</td>
                <td width="1" height="31" align="right" valign="bottom" bgcolor="#CBCBCB"></td>
              </tr>
            </table>
            </td>
            <td width="5" align="left">&nbsp;
            </td>
            <td align="right" class="f_5">
        		<a href="findAllOrganizationByTypeorganizationAction.action?organization.orgType=2">部门设置</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
   			</td>
           </tr>
        </table>
        </td>
      </tr>
      <tr>
        <td align="left" valign="top" class="tb_8 border_2"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td height="25" align="left" valign="middle"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="38%" align="left">按照用户分组 ┆ <a href="<%=path%>/findOfficialToDepartmentorganizationAction.action?user.userType=${sessionScope.UserInfo.userType}&years=${currentYear}&orgType=2&forwardPage=departmentToOff">按照部门分组</a> <br /></td>
                <td width="46%" align="right" valign="top">按年度查询：
                  <label>
                  <select name="select2" id="year" onchange="tdClick('<%=path %>/findOfficialToDepartmentorganizationAction.action?orgType=2&user.userType=${sessionScope.UserInfo.userType}&years='+this.value+'&forwardPage=offToDepartment');"><%-- 修改 &user.userType=${sessionScope.UserInfo.userType}--%>
                  </select>
                  </label></td>
                <td width="16%" style="border:solid #CCCCCC 1px;" align="right" class="f_4" onclick="changeEditor(this);" style="cursor:pointer;"><font color="#000000">设为编辑状态</font></td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td align="left" valign="top" style="position:relative;">
            <div id='myDiv' style=" position:relative;width:100%;height:500px;overflow:auto;" onscroll="floatTr(this)">
            	
            		  <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#DCDCDC">
		              <tr id='ftr' style='position:relative; top:0px;z-index:3'>
		                <td width="11%" height="30" align="center" bgcolor="#DBE9F6" class="f_4" >姓名</td>
		                <c:if test="${! empty AllOrganizationByType}">
		                <c:forEach items="${AllOrganizationByType}" var="org">
		                <td align="center" bgcolor="#DBE9F6">${org.name}</td>
		                </c:forEach>
		                </c:if>
		              </tr>
		              <c:if test="${! empty UserList}">
		              <c:forEach items="${UserList}" var="user" varStatus="i">
		              <tr>
		                <td height="30" bgcolor="#FFFFFF" align="center"> ${user.name }</td>
		                <c:forEach items="${AllOrganizationByType}" var="org" varStatus="j">
		                <td id="${i.count}-${j.count}" height="30" bgcolor="#FFFFFF" align="center" valign="middle" onclick="save('${user.userId}','${org.organizationId}','${i.count}-${j.count}')" onmouseover="this.style.backgroundColor='#e4f5ff'" onmouseout="this.style.backgroundColor=''" style="cursor:pointer;" title="点击设定用户部门">
		                	<c:if test="${! empty mapList}">
			                	<c:set value='${user.userId}${org.organizationId}' var="UserOrg"></c:set>
				                	<c:if test="${! empty mapList[UserOrg]}">
				                		√
				                	</c:if>
				                	<c:if test="${mapList[UserOrg]==null}">
				                		&nbsp;
				                	</c:if>
		                	</c:if>
		                	</td>
		                </c:forEach>
		              </tr>
		              </c:forEach>
		              </c:if>
		              <c:if test="${UserList==null}">
		              	<tr>
		              		<td colspan="2" height="30" align="center"><font color="red">没有查询到您要查找的信息</font></td>
		              	</tr>
		              </c:if>
		            </table>
            </div>
          </td>
          </tr>
        </table>
          <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td height="30" align="right"><shiyue:paging/></td>
            </tr>
          </table></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
    </table></td>
  </tr>
</table>
  </body>
</html>
<script>resize();</script>
